package de.tmahr.android;

import de.tmahr.android.logger.LogActivity;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.preference.PreferenceManager;

public class LifeCycleTestActivity extends LogActivity
{
	public LifeCycleTestActivity()
	{
		super("LifeCycleTestActivity");
	}	
	
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);		
		SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(this);
		log(p.getString("stringBuilder", ""));		
		log("onCreate");
	}
	
	@Override
	protected void onPause()
	{
		super.onPause();
		log("onPause");
		SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(this);
		Editor editor = p.edit();
		if(isFinishing())
		{
			log("isFinishing()==true");
			editor.putString("stringBuilder", "");
		}
		else
		{
			editor.putString("stringBuilder", getLoggedText());
		}
		editor.commit();
	}

	@Override
	protected void onStart()
	{
		super.onStart();
		log("onStart");
	}
	
	@Override
	protected void onStop()
	{
		super.onStop();
		log("onStop");
	}

	@Override
	protected void onDestroy()
	{
		super.onDestroy();
		log("onDestroy");
	}
	
	@Override
	protected void onResume()
	{
		super.onResume();
		log("onResume");
	}
	
	@Override
	protected void onRestart()
	{
		super.onRestart();
		log("onRestart");
	}
}